<template>
  <view>
    <u-popup
      mode="bottom"
      :round="25"
      :closeable="true"
      :show="popShow"
      @close="close"
    >
      <view class="pop-view">
        <view>
          <view class="title" v-if="!enoughMoney">{{
            $t("friend.chargeTitle")
          }}</view>
          <view class="title" v-else>{{ $t("friend.payTitle") }}</view>
        </view>
        <view class="price">{{ unit }}{{ price }}</view>
        <view>
          <view class="btn" v-if="!enoughMoney" @click="handleCharge">{{
            $t("friend.charge")
          }}</view>
          <view class="btn" v-else @click="handleConfirm">{{
            $t("index.Confirm")
          }}</view>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<script>
import uPopup from "../../../uni_modules/uview-ui/components/u-popup/u-popup.vue";
import { payPhoto, payChat } from "@/services/makeFriend";
export default {
  components: { uPopup },
  props: [
    "popShow",
    "price",
    "type",
    "userPersonalsId",
    "albumId",
    "enoughMoney",
    "unit",
  ],
  data() {
    return {};
  },
  methods: {
    close() {
      this.$emit("close");
    },
    async handleConfirm() {
      if (this.type == 1) {
        const resp = await payChat({ userPersonalsId: this.userPersonalsId });
        if (!resp.success) return;
        uni.navigateTo({
          url: `/pagesDiscover/friendsInformation/PaySuccess?userPersonalsId=${this.userPersonalsId}`,
        });
      } else if (this.type == 2) {
        const resp = await payPhoto({ albumId: this.albumId });
        if (!resp.success) return;
        uni.navigateTo({
          url: `/pagesDiscover/friendsInformation/PaySuccess?userPersonalsId=${this.userPersonalsId}`,
        });
      }
    },
    //充值
    handleCharge() {
      uni.navigateTo({
        url: "/pagesUser/bourse/bourse",
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.pop-view {
  padding: 30upx;
  text-align: center;
  margin-top: 30upx;
}
.title {
  font-size: 28upx;
  font-weight: 400;
  color: #fe6600;
  margin-top: 30upx;
}
.price {
  font-size: 48upx;
  font-weight: 500;
  color: #000000;
  margin-top: 30upx;
}
.btn {
  width: 100%;
  height: 80upx;
  font-size: 28upx;
  font-weight: 500;
  color: #ffffff;
  line-height: 80upx;
  margin-top: 70upx;
  background: #61bdb2;
  border-radius: 80upx;
}
</style>
